package test

import inc.veluvana.weatherforecaster.*

def printOrder(order) {
  /* print order content */
  order.getItems().each { k, v ->
    println "Type: ${k.cannonicalName} Unit Price: ${k.unitPrice} DeliveryTime: ${k.deliveryTime}\tAmount: ${v}"
  }
  // Calculate must be called before get Purchase price and delivery time
  println "\nPurchase Price: " + order.getPurchasePrice() + " DeliveryTime: " + order.getDeliveryTime() + "\n"
}
  
def order = new Order()

order.setAmount(Hardwood.CHERRY, 100)
order.setAmount(Hardwood.SAWDUST, 200)

printOrder(order)

// Add a new Hardwood type to OrderLoader
def h = new Hardwood(7, 5.0, 2.5, "custom_hardwood")
OrderLoader.addHardwood(h)

// Print all available order loader
println "Defined Hardwoods in OrderLoader"
OrderLoader.getDefinedHardwoods().each {
  k, v ->
  println " - ${k}"
}
println ""

  // modify order
order.setAmount(Hardwood.CHERRY, 50)
order.remove(Hardwood.SAWDUST)
printOrder(order)
